package bb.lanxing.model.database;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import com.alibaba.fastjson.annotation.JSONField;
//import com.orm.SugarRecord;
//import com.orm.dsl.Table;
import com.umeng.analytics.pro.d;

import bb.lanxing.common.config.Constants;
import bb.lanxing.model.BannerModel;
import bb.lanxing.util.CommonUtil;
import bb.lanxing.util.AppFileUtils;
import java.io.File;


public class LaunchBanner extends LitePalTableBase implements BannerModel, Parcelable {
    public static final Parcelable.Creator<LaunchBanner> CREATOR = new Parcelable.Creator<LaunchBanner>() {

        public LaunchBanner createFromParcel(Parcel parcel) {
            return new LaunchBanner(parcel);
        }


        public LaunchBanner[] newArray(int i) {
            return new LaunchBanner[i];
        }
    };
    @JSONField(name = "create_time")
    private long createTime;
    @JSONField(name = d.q)
    private long endTime;
    @JSONField(name = "extend_id")
    private long eventId;
    @JSONField(name = "pic_url")
    private String imageUrl;
    private int launchCount;
    @JSONField(name = "jump_desc")
    private String name;
    @JSONField(name = "ad_id")
    private long serverId;
    @JSONField(name = "show_count")
    private int showCount;
    @JSONField(deserialize = false, serialize = false)
    private long showTime;
    @JSONField(name = d.p)
    private long startTime;
    @JSONField(name = "jump_type")
    private int type;
    @JSONField(name = "extend_url")
    private String url;


    @Override
    public int describeContents() {
        return 0;
    }

    public LaunchBanner() {
    }



    public LaunchBanner(long j, long j2, long j3, String str, int i, String str2, long j4) {
        this.serverId = j;
        this.startTime = j2;
        this.endTime = j3;
        this.name = str;
        this.type = i;
        this.url = str2;
        this.eventId = j4;
    }

    public File getBannerImageFile() {
        if (TextUtils.isEmpty(this.imageUrl) || !AppFileUtils.isSdCardAvailable()) {
            return null;
        }
        String buildExternalDirectoryPath = AppFileUtils.buildExternalDirectoryPath(Constants.LAUNCH_IMAGE_DIR);
        return new File(buildExternalDirectoryPath, "launch_image_" + CommonUtil.getMD5(this.imageUrl));
    }

    public long getServerId() {
        return this.serverId;
    }

    public void setServerId(long j) {
        this.serverId = j;
    }

    public long getStartTime() {
        return this.startTime;
    }

    public void setStartTime(long j) {
        this.startTime = j;
    }

    public long getEndTime() {
        return this.endTime;
    }

    public void setEndTime(long j) {
        this.endTime = j;
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public String getBannerUrl() {
        return this.url;
    }

    public void setName(String str) {
        this.name = str;
    }

    public int getType() {
        return this.type;
    }

    public void setType(int i) {
        this.type = i;
    }

    public String getUrl() {
        return this.url;
    }

    public void setUrl(String str) {
        this.url = str;
    }

    @Override
    public int getBannerType() {
        return this.type;
    }

    public String getImageUrl() {
        return this.imageUrl;
    }

    public void setImageUrl(String str) {
        this.imageUrl = str;
    }

    @Override
    public long getEventId() {
        return this.eventId;
    }

    public void setEventId(long j) {
        this.eventId = j;
    }

    public long getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(long j) {
        this.createTime = j;
    }

    public long getShowTime() {
        return this.showTime;
    }

    public void setShowTime(long j) {
        this.showTime = j;
    }

    public int getLaunchCount() {
        return this.launchCount;
    }

    public void setLaunchCount(int i) {
        this.launchCount = i;
    }

    public int getShowCount() {
        return this.showCount;
    }

    public void setShowCount(int i) {
        this.showCount = i;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeLong(this.serverId);
        parcel.writeLong(this.startTime);
        parcel.writeLong(this.endTime);
        parcel.writeString(this.name);
        parcel.writeInt(this.type);
        parcel.writeString(this.url);
        parcel.writeString(this.imageUrl);
        parcel.writeLong(this.eventId);
        parcel.writeLong(this.createTime);
        parcel.writeLong(this.showTime);
        parcel.writeInt(this.launchCount);
        parcel.writeInt(this.showCount);
    }

    protected LaunchBanner(Parcel parcel) {
        this.serverId = parcel.readLong();
        this.startTime = parcel.readLong();
        this.endTime = parcel.readLong();
        this.name = parcel.readString();
        this.type = parcel.readInt();
        this.url = parcel.readString();
        this.imageUrl = parcel.readString();
        this.eventId = parcel.readLong();
        this.createTime = parcel.readLong();
        this.showTime = parcel.readLong();
        this.launchCount = parcel.readInt();
        this.showCount = parcel.readInt();
    }
}
